package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	
	public class PanelChatBubble extends JPanel
	{
		//members define
		private var txtBubble:JTextArea;
		public function PanelChatBubble()
		{
			//component creation
			setSize(new IntDimension(50, 34));
			var layout0:EmptyLayout = new EmptyLayout();
			setLayout(layout0);
			
			txtBubble = new JTextArea();
			txtBubble.setForeground(ASColor.WHITE);
			//txtBubble.setBackground(new ASColor(0x6600, 1));
			//txtBubble.setLocation(new IntPoint(5, 5));
			//txtBubble.setSize(new IntDimension(50, 34));
			txtBubble.setEditable(false);
			txtBubble.setWordWrap(true);
			
			//component layoution
			append(txtBubble);
			
			
			//var img_background:DisplayObject = Client.getUIElement("img_info_background") as DisplayObject
			//setBackgroundDecorator(new AssetBackground(img_background));
			//setSizeWH(img_background.width,img_background.height);
			txtBubble.setBackgroundDecorator(null);
			txtBubble.setBorder( new EmptyBorder);
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 10);
			txtBubble.setFont(font);
			txtBubble.filters = new Array(filter);
			
			
			//----------------------
			//txtBubble.setPreferredWidth(120);
			//txtBubble.setPreferredHeight(100);
			
			img_chat_bubble_1 = new AssetBackground(Client.getUIElement("img_chat_bubble_1") as DisplayObject);
			img_chat_bubble_2 = new AssetBackground(Client.getUIElement("img_chat_bubble_2") as DisplayObject);
		}
		private var img_chat_bubble_1:AssetBackground = null;
		private var img_chat_bubble_2:AssetBackground = null;
		public function setMessage(message:String):void
		{
			txtBubble.setHtmlText('  '+message);
			
			if(message.length < 20)
			{
				setBackgroundDecorator(img_chat_bubble_1);
				setPreferredSize(new IntDimension(140, 59));
				txtBubble.setPreferredSize(new IntDimension(134, 40));
				txtBubble.setLocation(new IntPoint(3, 3));
			}
			else
			{
				setBackgroundDecorator(img_chat_bubble_2);
				setPreferredSize(new IntDimension(140, 95));
				txtBubble.setPreferredSize(new IntDimension(134, 78));
				txtBubble.setLocation(new IntPoint(3, 3));
			}
			txtBubble.pack();
			txtBubble.paintImmediately();
			pack();
			paintImmediately();
		}
	}
}